var baseURL = "https://api.chihiro.hais.pw";

module.exports = function (option) {
  return new Promise(function (resolve, reject) {
    wx.request({
      url: baseURL + option.url,
      method: option.method,
      data: option.data === undefined ? '' : option.data,
      header: option.header === undefined ? {} : option.header,
      timeout: 5000,
      success(res) {
        if (res.data.code === 200) {
          resolve(res);
        } else {
          reject(res.data.message);
        }
      },
    })
  })
}